#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
int main()
{
    int orig = open("../01makelinkfile/test.file.orig", O_APPEND);
    if (orig == -1)
    {
        perror("open failed!\n");
        exit(-1);
    }
    // 写入内容
    write(orig, "1234", 5);
    printf("write 1234 to file test.file.orig...\n");
    close(orig);
    //打开另一个文件读
    int link = open("../01makelinkfile/test.file.link", O_RDONLY);
    if (link == -1)
    {
        perror("open failed!");
        exit(-1);
    }
    char buffer[5];
    read(link, buffer, sizeof(buffer));
    printf("read from test.file.link is : %s\n", buffer);
    //关闭文件
    close(link);
    return 0;
}